package cn.zhj.testjs;

import android.app.Activity;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

public class AndroidJs {
    Activity activity;
    public AndroidJs(Activity activity){
        this.activity = activity;
    }
    //js调用android关闭界面
    @JavascriptInterface
    public void back(String para) {
        Toast.makeText(activity , para , Toast.LENGTH_SHORT).show();
        Log.i("thisweb" , "para == " + para);
        activity.finish();
    }

    //js调用android获取userid
    @JavascriptInterface
    public String getUserId(String para) {
        Toast.makeText(activity , para , Toast.LENGTH_SHORT).show();
        return "android给你userid";
    }
}
